<!--
 * @Author: lwy 1245883359@qq.com
 * @Date: 2024-06-14 16:15:29
 * @LastEditors: lwy 1245883359@qq.com
 * @LastEditTime: 2024-06-17 09:29:03
 * @FilePath: \six-bird-operation-platform\src\views\salesAfter\components\apply.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <TheCreateForm
    ref="formRefs"
    :options="formOptions"
    :form.sync="form"
    title="申请售后"
    @submit="onSubmit"
  >
  </TheCreateForm>
</template>

<script>
import { validatePhone } from "@/utils/validate.js";
import { apiDictSaleType,apiOrderBApplyRefund } from "@/api/salesAfter.js";
export default {
  components: {},
  data() {
    return {
      viewApi: null,
      form: {},
      formOptions: [
        {
          type: "input",
          field: "serviceOrderId",
          title: "关联订单",
          placeholder: "输入订单编号（订单完结15天内）",
          rules: [
            { required: true, message: "请输入订单编号", trigger: "blur" },
          ],
        },
        {
          type: "select",
          field: "afterSaleType",
          title: "售后类型",
          placeholder: "售后类型",
          api: apiDictSaleType,
          optionKey: "dictLabel",
          optionValue: "dictLabel",
          maxlength: 100,
          rules: [
            { required: true, message: "请选择售后类型", trigger: "blur" },
          ],
        },
        {
          type: "textarea",
          field: "problem",
          title: "问题描述",
          maxlength: 100,
          placeholder: "问题描述...",
          rules: [
            { required: true, message: "请输入问题描述", trigger: "blur" },
          ],
        },
        {
          type: "input",
          field: "phone",
          title: "联系电话",
          maxlength: 11,
          placeholder: "联系电话...",
          rules: [
            { required: true, message: "请输入联系电话", trigger: "blur" },
            {
              trigger: "change",
              validator: validatePhone,
            },
          ],
        },
        {
          type: "upload",
          field: "proof",
          title: "上传证据",
          maxlength: 6,
          fileType: "text",
          default: [],
          rules: [{ required: true, message: "请上传证据", trigger: "change" }],
          accept:'.jpg,.png,.jpeg,.mp4,.mp3'
        },
      ],
      form: {},
    };
  },
  mounted() {},
  methods: {
    open(row) {
      this.$refs.formRefs.open(row);
    },
    onSubmit(values){
      apiOrderBApplyRefund({...values,proof:values.proof.join(',')}).then(res=>{
        this.$message({
          type:'success',
          message:'申请售后成功'
        })
        this.$emit('refresh')
      })
    }
  },
};
</script>
